/*
 * @Autor: dingxiaolin
 * @Date: 2021-07-21 07:55:12
 * @LastEditors: dingxiaolin
 * @LastEditTime: 2021-07-21 09:26:19
 */

import store from '@/store'
// 与vue2的里面的data一样，函数返回新对象防止多处共用同一对象,造成数据混乱
export const getFormSchema = (): FormSchema => ({
    col: 2,
    formItemLayout: {
        layout: "horizontal", labelCol: {
            xs: { span: 24 },
            sm: { span: 6 }
        },
        wrapperCol: {
            xs: { span: 24 },
            sm: { span: 18 }
        },
    },
    formItem: [
        {
            type: 'input',
            label: '日志名称',
            field: 'name',
            value: '',
            props: {
                disabled: true
            },
        },
        {
            type: 'select',
            label: '操作类型',
            field: 'opType',
            value: '',
            props: {
                disabled: true
            },
            asyncOptions: async () => {
                const data = await store.dispatch('enums/getEnum', 'op_type')
                return data.map((item) => ({
                    label: item.value,
                    value: Number(item.code)
                }))
            }
        },
        {
            type: 'select',
            label: '执行结果',
            field: 'success',
            value: '',
            props: {
                disabled: true
            },
            asyncOptions: async () => {
                const data = await store.dispatch('enums/getEnum', 'yes_or_no')
                return data.map((item) => ({
                    label: item.value,
                    value: item.code
                }))
            }
        },
        {
            type: 'input',
            label: '请求类型',
            field: 'reqMethod',
            value: '',
            props: {
                disabled: true
            },
        },
        {
            type: 'input',
            label: '操作时间',
            field: 'opTime',
            value: '',
            props: {
                disabled: true
            },
        },
        {
            type: 'input',
            label: '操作人',
            field: 'accountName',
            value: '',
            props: {
                disabled: true
            },
        },
        {
            type: 'textarea',
            label: '请求参数',
            field: 'param',
            value: '',
            props: {
                disabled: true
            },
        },
        {
            type: 'textarea',
            label: '返回结果',
            field: 'result',
            value: '',
            props: {
                disabled: true
            },
        },
    ]
})
